package com.example.zhyq.login

import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.alibaba.android.arouter.facade.annotation.Route
import com.alibaba.android.arouter.launcher.ARouter
import com.blankj.utilcode.util.ToastUtils
import com.example.base.mvvm.BaseActivity
import com.example.zhyq.R
import com.example.zhyq.databinding.ActivityRegisterBinding
import dagger.hilt.android.AndroidEntryPoint


@AndroidEntryPoint
@Route(path = "/app/RegisterActivity")
class RegisterActivity : BaseActivity<ActivityRegisterBinding,UserViewModel>() {


    override fun initView() {
        binding.btnRegister.setOnClickListener {

            val phone = binding.etPhone.text.toString()
            val pass = binding.etPass.text.toString()

            vm.register(phone,pass)
        }

        binding.gotoLogin.setOnClickListener {
            ARouter.getInstance().build("/app/LoginActivity").navigation()
            finish()
        }
    }

    override fun initData() {
        vm.registerSuc.observe(this) {
            ToastUtils.showLong("注册成功")
            ARouter.getInstance().build("/app/LoginActivity").navigation()
        }
    }
}